package br.uefs.ecomp.myBook.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.TextArea;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.Border;

import br.uefs.ecomp.myBook.model.GeneralPost;
import br.uefs.ecomp.myBook.model.MyBookSystem;
import br.uefs.ecomp.myBook.util.ImageOperations;


public class GeneralPostPanel extends JPanel {

	private GeneralPost post;

	public GeneralPostPanel(GeneralPost post){
		this.post = post;
		initializeComponents();
	}

	private void initializeComponents() {
			
		setLayout(new BorderLayout(0, 5));
		
		JPanel header = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
		
		JLabel privacy = new JLabel(ImageOperations.scaleIcon(
		new ImageIcon(MyBookSystem.PATH+MyBookSystem.ICONFOLDER+"privacy.png"), new Dimension(24, 24)));
		
		privacy.setToolTipText(post.getVisibility().toString());				
				
		header.add(privacy);
		header.add(new MyBookTitle(post.toString(), 12));
		header.setOpaque(false);
		
		JTextArea center = new JTextArea(post.getMessage());
		center.setEditable(false);
		center.setFocusable(false);
		center.setOpaque(false);

		center.setWrapStyleWord(true);
		center.setLineWrap(true);
		
		add(header, BorderLayout.NORTH);
		add(center, BorderLayout.CENTER);
		
		
		revalidate();
		repaint();
	}


	
}
